<% content_for :sidebar do %>
  <%= sidebar_button_link 'New Item Category', new_item_category_path if can? :create, ItemCategory %>
<% end %>

<table id="item_categories" class="generic_datatable table table-striped table-bordered">
  <caption><h3><%= @page_title %></h3></caption>
  <thead>
    <tr>
      <th>Category Name</th>
    </tr>
  </thead>

  <tbody>
    <% @item_categories.each do |itc| %>
      <tr>
        <td><%= link_to itc.name, itc %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<% if @repairs.length > 0 %>
  <hr />
  <h3> Repairs</h3>
  <table id="repair_items" class="generic_datatable table table-striped table table-bordered">
    <thead>
      <tr>
        <th>Item Name</th>
        <th>Service Date</th>
        <th>Status</th>
        <th>Description</th>
        <th>Repairer</th>
        <th>Cost</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @repairs.each do |repair|%>
        <tr>
          <td><%= link_to repair.item.name, item_path(repair.item) %></td>
          <td><%= repair.service_date%></td>
          <td><%= repair.status %></td>
          <td><%= repair.description %></td>
          <td><%= repair.repairer_name %></td>
          <td><%= repair.cost %></td>
          <td><%= table_button_link 'Edit', edit_repair_path(repair) %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% end %>
